﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MotoGame.Estados.Menu;

namespace MotoGame.Estados.Credito
{
    class Creditos : EstadoBase
    {
        SpriteFont arial;
        Botao voltar;

        public Creditos(MainGame game) : base(game) 
        {
            arial = Game.Content.Load<SpriteFont>("arial");

            int width = 100;
            int height = 25;
            int screenWidth = Game.Window.ClientBounds.Width;
            int screenHeight = Game.Window.ClientBounds.Height;
            int spacing = 100;

            voltar = new Botao(
                Game.GraphicsDevice,
                arial,
                new Rectangle(
                    (screenWidth - width) / 2, (screenHeight - height) / 2 + spacing,
                    width, height),
                "Voltar",
                (button) => { Game.StateManager.GoTo(MainGame.Estado.Menu); });
        }

        public override void Update(GameTime gameTime)
        {
            voltar.Update(gameTime);
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            string text = "Autor: Humberto Anjos\nProfessor: Cléber Tavares Jr.";
            int screenWidth = Game.Window.ClientBounds.Width;
            int screenHeight = Game.Window.ClientBounds.Height;
            Vector2 textSize = arial.MeasureString(text);
            Vector2 textCenter = new Vector2(screenWidth / 2, screenHeight / 2); 

            spriteBatch.DrawString(arial, text, textCenter - (textSize / 2), Color.Red);

            voltar.Draw(gameTime, spriteBatch);
        }
    }
}
